# 复制整行： Ctrl + D
# 格式化：Ctrl + Alt + L
# 整体标注：Ctrl + /

# # 进制表示
# """
# 2进制: 0,1  以0b或者 0B开头
# 8进制: 0-7  以0o或者 0O开头
# 10进制: 0-9
# 16进制: 0-9 & A(10)-F(15)-->此处的af不区分大小写      以0X或者 0x开头
#
# """
#
# print(0b1001)
# print(0o1001)
# print(1001)
# print(0x1001)
#
# # 单分支接直接上代码
# """
# 1.基本语法
# if 条件表达式:
#     代码块..
#
# 2.当条件表达式为True时，就会执行代码块;否则不执行
#
# 3.Python缩进非常重要,时用于界定代码块的，相当于其他编程语言里的大括号{}
#
# """
# if 3 < 1:
#     print("for what1")
#     print("for what2")
#
# print("for what3")  # 这条和上面两条不是同一个代码块
#
# # 4 最短的缩进对较长的有包含关系，缩进前后没有要求，但是每个代码块应该具有相同的缩进长度（嵌套if语句）
# if 3 > 2:
#     print("for what4")
#     print("for what5")
#     if 3 < 4:
#         print("for what6")
#
# # exercise
# age = int(input("Please enter your age: "))
# if age < 18:
#     print("Your age is too low")
# if age >= 18:
#     print("Your age is too high")
#
# # 双分支接直接上代码
# #1.判断年龄
# age = int(input("Please enter your age: "))
# if age < 18:
#     print("You should be responsible for yourself,go home now")
# else:
#     print("You will be arrested.")

# #2.定义两个整数如果和大于等于50，则输出“hello world”
# num1 = int(input("Please enter your first number: "))
# num2 = int(input("Please enter your first number: "))
# if (num1 + num2) >= 50:
#     print("Your number is too big")

# #3.两个浮点数如果num1 > 10.0且num2 < 20.0则打印这两个数
# num1 = float(input("Please enter your first number: "))
# num2 = float(input("Please enter your first number: "))
# if num1 > 10.0 and num2 < 20.0:
#     print(str(num1) +"\t" +  str(num2))
#     print(f"{num1}\t{num2}")

# #4.两个整数的和是否能被3或5整除
# num1 = int(input("Please enter your first number: "))
# num2 = int(input("Please enter your first number: "))
# if (num1 + num2) % 3 ==0 or (num1 + num2) % 5 ==0:
#     print(f"{num1}和{num2}的和可以被被3或5整除 ")

# #5.经典老题目：求闰年
# year = int(input("Please enter your first number: "))
# if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
#     print(f"{year}是闰年")


# 多分支接直接上代码

# exe2 逆天小题目
# height = int(input("身高为:"))
# money = float(input("财产为:"))
# say = str(input("帅吗?"))
# if say == "帅" and money > 10000000 and height > 180:
#     print("此人非嫁不可")
# elif say == "不帅" or money > 10000000 or height > 180:
#     print("勉勉强强吧")
# else:
#     print("想吃天鹅肉？没门！")


# 嵌套分支接直接上代码

# exe1曾经在用java写过
# score = float(input("Enter score: "))
# if score >= 8.0:
#     print("已进入决赛")
#     gender = str(input("Enter gender: "))
#     if gender == "男":
#         print(f"你已进入男子组,成绩为{score},性别为{gender}")
#     elif gender == "女":
#         print(f"你已进入女子组,成绩为{score},性别为{gender}")
# else:
#     print("你已出局！")

# exe2曾经在用java写过
# month = int(input('Enter a month: '))
# age = int(input('Enter your age: '))

# if 1 <= month <= 12 and 1 <= age <= 130:
#     if 4 <= month <= 10:
#         if age < 18:
#             print('半价')
#         elif 18 <= age <= 60:
#             print("60元")
#         elif age > 60:
#             print("1/3票价")
#     else:
#         if 18 <= age <= 60:
#             print("40元")
#         else:
#             print("20元")
# else:
#     print('Invalid input')


# for循环接上代码

"""
    for <变量> in <范围/序列>:
    <循环操作语句>

"""
import random

# num = [1, 2, 3, 4, 5, 6, 7, 8, 9]  # 利用列表进行操作！！！
# for a in num:
#     print(a)
#
# for a in range(1,10):  # 但是这个使得代码更加清爽，range()前闭后开
#     print(a)

# 证明列表相关的id问题
# num = [1, 2, 3, 4, 5]
# for a in num:
#     print(id(num), a, id(a))
# print("================================")
# num = [1, 2, 3, 4, 5]
# for a in num:
#     print(id(num), a, id(a))
"""
    summary:
    1.列表是引用类型，并且只能创建一个新的空间定义一个新的列表
    2.数字只会开辟一个空间不会换
    3.

"""

# range()解读

# range()前闭后开
# for a in range(1,11):
#     print(a)

# range三种输出格式

"""
range(start=0,stop,step=1)
start默认为零，step默认为1
"""
#
# print(list(range(11)))  # 默认从0开始
# print(list(range(1,11)))
# print(list(range(1,11,2)))

# for else组合
# nums=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
# for a in nums:
#     print(a)
# else:
#     print(nums)


# while循环
# a = 10
# while a < 20:
#     print(a)
#     a = a + 1


# while else组合
# i = 100
# while i > 0:
#     print(i)
#     i -= 1
# else:
#     print("浮游")

# exe1 打印1-100所有被3整除的数
# i = 1
# while i <= 100:
#     if i % 3 == 0:
#         print(i)
#     i += 1

# exe2 打印40-200所有偶数
# j = 40
# while j <= 200:
#     if j % 2 == 0:
#         print(j)
#     j += 1

# 不断输入姓名直到exit为止

# while True:
#     name = input("请输入姓名:")
#     if name == "exit":
#         break


# 打印1-100之间所有是9的倍数的数，统计个数和总和
# sum = 0
# id = 0
# i = 0
# while i <= 100:
#     if i % 9 == 0:
#         print(i)
#         sum += i
#         id += 1
#     i += 1
# print(id)
# print(sum)

# 倒序输出
# num = int(input("请输入一个整数"))
# i = 0
# j = num
# while i <= num:
#     print(str(i) + "\t+\t" + str(j) + "\t=\t" + str(num))
#     i += 1
#     j -= 1


# 多重循环

# exe1统计及格人数 （有时间再用for写写试试）
# sum = 0
# i = 1
# while i <= 15:
#     if 0 <= i <= 5:
#         score1 = int(input(f"一班第{i}个同学分数:"))
#         i += 1
#         if score1 >= 60:
#             sum += 1
#     elif 5 <= i <= 10:
#         score2 = int(input(f"二班第{i-5}个同学分数:"))
#         i += 1
#         if score2 >= 60:
#             sum += 1
#     elif 10 <= i <= 15:
#         score3 = int(input(f"二班第{i - 10}个同学分数:"))
#         i += 1
#         if score3 >= 60:
#             sum += 1
# print(sum)


# break

# 随机数到97之间用了多少次机会？
# import random  # 导不导这个包都无所谓
# sum = 0
# while True:
#     a = random.randint(1,100)  # 这个东西是闭区间！！！
#     sum += 1
#     if a == 97:
#         break
# print(sum)

# exe1  1-100以内求和，当和第一次大于20当前的变量值为多少
sum = 0
for i in range(1,101):
    sum += i
    if sum > 20:
        print(i)
        break
    i += 1

# for + break完成登录验证
for i in range(1,5):
    name = input("请输入姓名:")
    code = input("请输入密码:")
    if code == "888" and name == "张无忌":
        print("成功登录!!!")
        break
    else:
        print(f"还有{4-i}次机会")





























































